/**
 * Created by mooshroom on 2015/3/2.
 */
define('autoFace', function () {
    return autoFace = avalon.define({
        $id: 'autoFace',
        username: "",
        username2: "",
        usernameList: [],
//颜色集合
        backGroundColor: ["#0099FF","#6699FF","#9933FF","#993333","#9999FF","#99CCFF","#CC3300","#CC6633","#CCFF99","#FFCC33","#CCCCCC"],

//        执行自动生成函数
        faceCreate: function () {

            require.config({
                path: {

                }
            });
            require(['css!../css/auto-face'], function () {

                var faceList = [];
                faceList = document.getElementsByClassName("autoface");

                for (var i = 0; i < faceList.length; i++) {

                    var faceWord = faceList[i].getAttribute("face-ower").charAt(0).toUpperCase();
                    var subWord=faceList[i].getAttribute("face-ower").charAt(1);

                    faceList[i].innerHTML = faceWord;

                    //计算背景色

                    var n = (faceWord.charCodeAt()+subWord.charCodeAt()) % autoFace.backGroundColor.length;


                    //计算前景色
                    var o = faceWord.charCodeAt() % 2;
                    if (o == 0) {
                        faceList[i].setAttribute("style", "color:#ffffff;background-color:" + autoFace.backGroundColor[n])
                    }
                    else{
                        faceList[i].setAttribute("style", "background-color:" + autoFace.backGroundColor[n]);
                    }
                }
            })


        }

    })
})